<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>待反馈上报任务</title>
    <#include "/common/resource.ftl">
    <script type="text/javascript">
        var getSearchParams = function(){
            return {
                title:$("input[name='title']").val() || "",
            };
        }
    </script>
</head>
<body class="bg-gray">

   <div class="ui-operation">
       <div class="ui-buttons">
   		 <div class="layui-btn-group tools">
   		 	<!-- <button class="layui-btn layui-btn-normal sign-button" reurl="${params.contextPath}/web/taskActor/sign.json">
				<i class="fa fa-location-arrow"></i>签收
			</button> -->
			<button class="layui-btn layui-btn-normal report-button" p="url:'${params.contextPath}/view/icip/datareport/datareport_form.htm',title:'上报数据',width:'800px',height:'90%'">
				<i class="fa fa-pencil"></i>上报数据
			</button>
         </div>
         <div class="ui-searchs">
             <div class="value" style="">
                 <input type="text" name="title" placeholder="任务标题">
             </div>
             <input type="button" value="搜索" class="layui-btn layui-btn-danger search-button"/>
         </div>
       </div>
   </div>
   <div class="ui-content" style="padding-left: 10px;padding-right:10px;">
       <table id="datagrid"
              options="url:'${params.contextPath}/web/taskActor/undoList.json',params:'getSearchParams',dblClickRow:'showDetail'">
           <thead>
           <tr>
               <th data-options="field:'stateStr',width:60,formatter:formatState">报送状态</th>
               <th data-options="field:'priorityStr',width:60,formatter:formatPriority">优先级</th>
              <!--  <th data-options="field:'editableStr',width:60,formatter:formatEditable">允许上报</th> -->
               <th data-options="field:'taskTitle',width:150,formatter:formatTitle">任务标题</th>
               
               <th data-options="field:'publishTimeStr',width:120">要求报送日期</th>
               <!-- <th data-options="field:'deadTimeStr',width:120">截止时间</th> -->
               <th data-options="field:'completeTimeStr',width:120">实际报送时间</th>
               <th data-options="field:'publishCreateName',width:80">发布人</th>
               <th data-options="field:'publishOrgName',width:100">发布单位</th>
           </tr>
           </thead>
       </table>
   </div>
   
</body>
<script type="text/javascript">
    function showDetail (index, row) {
        var url = "${params.contextPath}/view/icip/datareport/datareport_report_detail.htm?id=" + row.id;
        DialogManager.openDialog("url:'" + url + "',title:'上报详情',width:'50%',height:'50%'");
    };

function formatState(val, row) {
    if (row.state == 3) {
        return '<span class="ui-warn">' + val + '</span>';
    } else if(row.state == 2){
        return '<span class="ui-accept">' + val + '</span>';
    }else if(row.state == 1){
    	return '<span class="ui-stop">' + val + '</span>';
    }
    return val;
}

function formatTitle(val, row) {
    
    return "【"+row.publishTimeCNStr+"】"+val;
}

function formatPriority(val, row) {
    if (row.priority == 1) {
        return '<span class="ui-accept">' + val + '</span>';
    } else if(row.priority == 2){
        return '<span class="ui-warn">' + val + '</span>';
    }else if(row.priority == 3){
    	return '<span class="ui-stop">' + val + '</span>';
    }
    return val;
}

function formatEditable(val, row) {
    if (row.editable == 1) {
        return '<span class="ui-accept">' + val + '</span>';
    } else if(row.editable == 2){
        return '<span class="ui-stop">' + val + '</span>';
    }
    return val;
}

function formatPriority(val, row) {
    if (row.priority == 1) {
        return '<span class="ui-accept">' + val + '</span>';
    } else if(row.priority == 2){
        return '<span class="ui-warn">' + val + '</span>';
    }else if(row.priority == 3){
        return '<span class="ui-stop">' + val + '</span>';
    }
    return val;
}

$(function(){
	$(".sign-button").click(function() {
		var id = DataGrid.getSelectId();
		if (id == "") {
			layer.msg("请选择需要签收的任务");
			return false;
		}
		var url = $(this).attr("reurl");
		layer.confirm('确定签收该任务吗?', function() {
			$.ajaxRequest({
				url : url,
				data : {
					id : id
				},
				success : function(data) {
					$.message(data.message);
					if (data.success) {
						DataGrid.reload();
					}
				}
			});
		});
		
	});
	$(".report-button").click(function() {
		DialogManager.singleSelected2($(this),function(row,params){
			if(row.state==3){
				layer.msg("该任务已锁定,不可上报数据");
				return false;
			}
			/* if(row.editable!=1){
                layer.msg("该任务已锁定,不可上报数据");
                return false;
            } */
			params.url = $.getUrl(params.url, "id", row.id);
			return true;
		});
	});
	
});
</script>
</html>
